package com.example.demo.restcontroller;


import com.example.demo.entity.StudentSource;
import com.example.demo.entity.User;
import com.example.demo.service.StudentSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


//解决跨域请求的问题
@CrossOrigin
@RestController
public class IndexRestController {

    @Autowired
    StudentSourceService studentSourceService;


    @GetMapping("/getStudentSourceList")
    public Map<String, Object> getStudentSourceList() {
        HashMap<String, Object> map = new HashMap<>();
        List<StudentSource> result = studentSourceService.getStudentSourceList();
        if (result != null) {
            map.put("code", 200);
            map.put("obj", result);
        } else {
            map.put("code", -1);
        }
        return map;
    }

    @GetMapping("/todayVisitCount")
    public int todayVisitCount(){
        return 120;
    }

    @GetMapping("/todayLendBookCount")
    public int todayLendBookCount(){
        return 30;
    }

    @GetMapping("/todayBorrowBooKCount")
    public int todayBorrowBooKCount(){
        return 10;
    }

    @GetMapping("/todayBookCount")
    public int todayBookCount(){
        return 1150;
    }

}
